package org.gitos.cloud.util;

import java.io.Serializable;

import com.alibaba.fastjson.JSONObject;

/**
 * 类JSession.java的实现描述：自定义的session,存放在redis中
 * 
 * @author shizc 2015年7月13日 下午7:23:41
 */
@SuppressWarnings({ "rawtypes" })
public class JSession implements Serializable {

	private static final long serialVersionUID = -8295069955352206548L;

	private final String globalSessionId = CommonKit.createUuid();
	private final long createTime = System.currentTimeMillis();
	private long lastAccessedTime;
	private String data;
	private int maxInactiveInterval;
	private boolean invalidate;

	public long getLastAccessedTime() {
		return lastAccessedTime;
	}

	public void setLastAccessedTime(long lastAccessedTime) {
		this.lastAccessedTime = lastAccessedTime;
		RedisHelper.setJSession(this);
	}

	public String getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = JSONObject.toJSONString(data);
		RedisHelper.setJSession(this);
	}

	public int getMaxInactiveInterval() {
		return maxInactiveInterval;
	}

	public void setMaxInactiveInterval(int maxInactiveInterval) {
		this.maxInactiveInterval = maxInactiveInterval;
		RedisHelper.setJSession(this);
	}

	public boolean isInvalidate() {
		return invalidate;
	}

	public void setInvalidate(boolean invalidate) {
		this.invalidate = invalidate;
		RedisHelper.setJSession(this);
	}

	public String getGlobalSessionId() {
		return globalSessionId;
	}

	public long getCreateTime() {
		return createTime;
	}

}
